#!/usr/bin/python
# author dennis
# 2022年06月15日
import multiprocessing
import threading
import time


def work():
    for i in range(10):
        print("工作...")
        time.sleep(0.2)


if __name__ == '__main__':
    work_thread = threading.Thread(target=work)
    work_thread.start()
    time.sleep(1)
    print("主线程执行完毕")

    # 守护主线程
    # 方式一：参数方式
    work_thread = threading.Thread(target=work,daemon=True)
    work_thread.start()
    time.sleep(1)
    print("主线程执行完毕")

    # 方式二
    work_thread = threading.Thread(target=work)
    work_thread.setDaemon(True)
    work_thread.start()
    time.sleep(1)
    print("主线程执行完毕")